package leafedbox.managers
{
	import mx.controls.dataGridClasses.DataGridColumn;
	
	/**
	 * This class controls the formatting of data types.
	 */
	public class LocaleManager
	{
		//------------------------------------------------------------------------------
		// Static properties
		//------------------------------------------------------------------------------
		
		protected static var impl : LocaleManagerImpl = new LocaleManagerImpl();


		//------------------------------------------------------------------------------
		// Methods
		//------------------------------------------------------------------------------
		
		//----------------------------------
		// Singleton
		//----------------------------------

		/**
		 * Returns the implementation.
		 */
		public static function getInstance():LocaleManagerImpl
		{
			return impl;
		}
		
		
		//----------------------------------
		// Formatting
		//----------------------------------

		/**
		 * @private
		 */
		public static function formatNumber(value:Number, precision:int=2, useThousandsSeparator:Boolean=true):String
		{
			return impl.formatNumber(value, precision, useThousandsSeparator);
		}
		
		/**
		 * @private
		 */
		public static function formatInt(value:int, useThousandsSeparator:Boolean=true):String
		{
			return impl.formatInt(value, useThousandsSeparator);
		}
		
		/**
		 * @private
		 */
		public static function formatCurrency(value:Number, precision:int=2, useThousandsSeparator:Boolean=true):String
		{
			return impl.formatCurrency(value, precision, useThousandsSeparator);
		}
		
		/**
		 * @private
		 */
		public static function formatBoolean(value:*):String
		{
			return impl.formatBoolean(value);
		}
		
		/**
		 * @private
		 */
		public static function formatPercent(value:Number, precision:int=2, useThousandsSeparator:Boolean=true):String
		{
			return impl.formatPercent(value, precision, useThousandsSeparator);
		}
		
		/**
		 * @private
		 */
		public static function formatDuration(value:int):String
		{
			return impl.formatDuration(value);
		}
		
		/**
		 * @private
		 */
		public static function formatDateTime(value:Date):String
		{
			return impl.formatDateTime(value);
		}

		/**
		 * @private
		 */
		public static function formatDate(value:Date):String
		{
			return impl.formatDate(value);
		}

		/**
		 * @private
		 */
		public static function formatShortDate(value:Date):String
		{
			return impl.formatShortDate(value);
		}

		/**
		 * @private
		 */
		public static function formatMonth(value:Date):String
		{
			return impl.formatMonth(value);
		}

		/**
		 * @private
		 */
		public static function formatTime(value:Date):String
		{
			return impl.formatTime(value);
		}


		//----------------------------------
		// Label functions
		//----------------------------------


		/**
		 * @private
		 */
		public static function formatNumber_labelFunction(item:Object, column:DataGridColumn):String
		{
			return formatNumber(item[column.dataField]);
		}
		
		/**
		 * @private
		 */
		public static function formatInt_labelFunction(item:Object, column:DataGridColumn):String
		{
			return formatInt(item[column.dataField]);
		}
		
		/**
		 * @private
		 */
		public static function formatCurrency_labelFunction(item:Object, column:DataGridColumn):String
		{
			return formatCurrency(item[column.dataField]);
		}
		
		/**
		 * @private
		 */
		public static function formatBoolean_labelFunction(item:Object, column:DataGridColumn):String
		{
			return formatBoolean(item[column.dataField]);
		}
		
		/**
		 * @private
		 */
		public static function formatPercent_labelFunction(item:Object, column:DataGridColumn):String
		{
			return formatPercent(item[column.dataField]);
		}
		
		/**
		 * @private
		 */
		public static function formatDuration_labelFunction(item:Object, column:DataGridColumn):String
		{
			return formatDuration(item[column.dataField]);
		}
		
		/**
		 * @private
		 */
		public static function formatDateTime_labelFunction(item:Object, column:DataGridColumn):String
		{
			return formatDateTime(item[column.dataField]);
		}

		/**
		 * @private
		 */
		public static function formatDate_labelFunction(item:Object, column:DataGridColumn):String
		{
			return formatDate(item[column.dataField]);
		}

		/**
		 * @private
		 */
		public static function formatShortDate_labelFunction(item:Object, column:DataGridColumn):String
		{
			return formatShortDate(item[column.dataField]);
		}

		/**
		 * @private
		 */
		public static function formatMonth_labelFunction(item:Object, column:DataGridColumn):String
		{
			return formatMonth(item[column.dataField]);
		}

		/**
		 * @private
		 */
		public static function formatTime_labelFunction(item:Object, column:DataGridColumn):String
		{
			return formatTime(item[column.dataField]);
		}
	}
}